<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>微信登录成功</title>
</head>

<body>
<div style="width:100%;height:300px;text-align:center;display: none;">
  <h1>微信登录成功</h1>
  <p><a href="https://www.sacasaca.com">返回首页</a></p>
</div>
</body>
<script src="https://www.sacasaca.com/jquery.min.js"></script>
<script type="text/javascript">
{/* setTimeout(function(){
	window.location.href = "https://www.sacasaca.com";
}, 500000) */}
let codeString = ''
let codeString2 = ''
let code = ''
let saca_token2 = ''
console.log(window.location.href.indexOf('?'));
if ( window.location.href.indexOf('?') > -1) {
  codeString = window.location.href.split('?')[1]
  codeString2 = codeString.split('&')[0]
  code = codeString2.split('=')[1]
  console.log(saca_token2);
} else {
    // localStorage.setItem('saca_token', 1)
    // const a = localStorage.getItem('saca_token')
    // console.log(a);
}

// localStorage.setItem('v3-admin-vite-username-key', 'saca用户10001' );
// localStorage.setItem('v3-admin-vite-user-id-key', '10001' );
  if (code) {
    // 通常这里会调用后端的 callback 接口，用 code 换取 token
    wechatScanLoginApi({code})
  }
  function wechatScanLoginApi(data) {
      $.ajax({
        url: 'https://www.sacasaca.com/shop122/wechatScanLogin',
        type: 'POST',
        data,
        success: function(res) {
          if(res.code === 0) {
            console.log('微信登录成功:', res.data);
            window.location.href = "https://www.sacasaca.com/#/wechatlogin"+"?id="+res.data.id+"&token="+res.data.token + "&username=" + 'saca用户' + res.data.id;
          } else {
            console.log('微信登录失败:', res.msg);
          }
        },
        error: function(err) {
          console.log(err)
        }
      })
  }
</script>

</html>
